﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class BagPanel : BasePanel<BagPanel>
{
    public ScrollRect svItems;
    public Button btnClose;

    void Start()
    {
        //第一步:动态创建n个图标，作为滚动视图中显示的内容
        for (int i=0; i<100; i++)
        {
            GameObject item = Instantiate(Resources.Load<GameObject>("Prefab/Item"));
            item.transform.SetParent(svItems.content, false);
            //设置格子的位置
            item.transform.localPosition = new Vector3(10, -10, 0) + new Vector3(i % 4 * 155, i / 4 * -155);
        }
        //第二步：设置Content的高
        svItems.content.sizeDelta = new Vector2(0, Mathf.CeilToInt(100/4) * 155);
        this.Hide();
        btnClose.onClick.AddListener(() =>
        {
            this.Hide();
        });
    }
}
